package com.persondemo.videoappliction.ui.dianping.presenter;

import com.persondemo.videoappliction.bean.DianPingDetilsBean;
import com.persondemo.videoappliction.bean.UpPingCeBean;
import com.persondemo.videoappliction.bean.UpimgBean;
import com.persondemo.videoappliction.net.BaseApi;
import com.persondemo.videoappliction.net.BaseObserver;
import com.persondemo.videoappliction.net.RxSchedulers;
import com.persondemo.videoappliction.ui.base.BaseContract;
import com.persondemo.videoappliction.ui.base.BasePresenter;
import com.persondemo.videoappliction.ui.dianping.contract.PingLunContract;

import javax.inject.Inject;

import okhttp3.MultipartBody;

public class PinglunPresenter extends BasePresenter<PingLunContract.View> implements PingLunContract.Presenter {
    BaseApi baseApi;

    @Inject
    public PinglunPresenter(BaseApi baseApi) {
        this.baseApi = baseApi;
    }


    @Override
    public void upimgdata(MultipartBody.Part file) {
        baseApi.upimgdata_pingce(file)
                .compose(RxSchedulers.applySchedulers())
                .compose(mView.bindToLife())
                .subscribe(new BaseObserver<UpimgBean>() {
                    @Override
                    public void onSuccess(UpimgBean upimgBean) {
                        mView.imgdata(upimgBean);
                    }

                    @Override
                    public void onFail(Throwable e) {
                        mView.showFaild();
                    }
                });
    }

    @Override
    public void uppingce(String ids, String content, String deivce, String imgs, String star) {
        baseApi.uppingce(ids, content, deivce, imgs, star)
                .compose(RxSchedulers.applySchedulers())
                .compose(mView.bindToLife())
                .subscribe(new BaseObserver<UpPingCeBean>() {
                    @Override
                    public void onSuccess(UpPingCeBean upPingCeBean) {
                        mView.loadpingce(upPingCeBean);
                    }

                    @Override
                    public void onFail(Throwable e) {
                        mView.showFaild();
                    }
                });
    }
}
